{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-09T18:10:58.265292Z",
     "start_time": "2020-07-09T18:10:57.648816Z"
    },
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "http://viapi-customer-temp.oss-cn-shanghai.aliyuncs.com/LTAI4G7iqc9nTRmEFPuYygZE/f12a9bfd-19cc-4b66-b560-594f3645346c.jpg\n"
     ]
    }
   ],
   "source": [
    "# 生成图片内部URL\n",
    "from viapi.fileutils import FileUtils\n",
    "file_utils = FileUtils(\)\n",
    "oss_url = file_utils.get_oss_url(\"https://ae01.alicdn.com/kf/H1f3535b626734ef5a6e473535195d2bfS.jpg\",\"jpg\",False)\n",
    "print(oss_url)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 34,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-09T16:43:34.887192Z",
     "start_time": "2020-07-09T16:43:34.451905Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"RequestId\":\"4664EDF1-5A97-44BB-B30C-EA7C7322B4B0\",\"Data\":{\"RetainLocation\":{\"X\":566,\"Y\":566,\"Height\":500,\"Width\":500},\"Url\":\"http://viapi-cn-shanghai-dha-filter.oss-cn-shanghai.aliyuncs.com/upload/result_filter/2020-7-10/invi_filter_015943130155771000878_bShNkU.jpg?Expires=1594314815&OSSAccessKeyId=LTAI4FoLmvQ9urWXgSRpDvh1&Signature=bXIki6JPJtlQyOfMnjB%2FO3VRDRg%3D\"}}\n"
     ]
    }
   ],
   "source": [
    "#超分辨/清晰化\n",
    "\n",
    "from aliyunsdkcore.client import AcsClient\n",
    "from aliyunsdkcore.request import CommonRequest\n",
    "client = AcsClient('LTAI4G9jhGT9jJSGAgPSXzmC', 'J2Hm3NUQJhU47AAyc3K9pNvpX4dprW', 'cn-shanghai')\n",
    "\n",
    "request = CommonRequest()\n",
    "request.set_accept_format('json')\n",
    "request.set_domain('imageenhan.cn-shanghai.aliyuncs.com')\n",
    "request.set_method('POST')\n",
    "request.set_protocol_type('https') # https | http\n",
    "request.set_version('2019-09-30')\n",
    "request.set_action_name('ChangeImageSize')\n",
    "\n",
    "request.add_query_param('RegionId', \"cn-shanghai\")\n",
    "request.add_query_param('Width', \"500\")\n",
    "request.add_query_param('Height', \"500\")\n",
    "request.add_query_param('Url', \"http://explorer-image.oss-cn-shanghai.aliyuncs.com/1630271561302452/f907fa8d-6355-48ed-beef-07deb254a441.jpg?OSSAccessKeyId=LTAI4Fk9FstqSEYnqKJ5Dpeo&Expires=1594313597&Signature=gkz0wHyemzGF%2BbQ%2BNFpx1DdaUR4%3D\")\n",
    "\n",
    "response = client.do_action(request)\n",
    "print(str(response, encoding='utf-8'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-09T18:03:06.853668Z",
     "start_time": "2020-07-09T18:03:06.018137Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"Message\":\"success\",\"RequestId\":\"09A38A26-8604-4150-8CDF-500AA6758EED\",\"Data\":{\"Url\":\"http://ivpd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/upload/result_/2020-7-10/invi__015943177872061004413_z59WWf.jpg?Expires=1594321387&OSSAccessKeyId=LTAI4FeJ8qKkYn6SrHhQ1DZQ&Signature=WUNAERU9Tk%2BLNGjeNb6siJeEEA8%3D\"},\"Code\":\"0\"}\n"
     ]
    }
   ],
   "source": [
    "#超分辨/清晰化\n",
    "from aliyunsdkcore.client import AcsClient\n",
    "from aliyunsdkcore.acs_exception.exceptions import ClientException\n",
    "from aliyunsdkcore.acs_exception.exceptions import ServerException\n",
    "from aliyunsdkivpd.request.v20190625.MakeSuperResolutionImageRequest import MakeSuperResolutionImageRequest\n",
    "\n",
    "client = AcsClient('LTAI4G9jhGT9jJSGAgPSXzmC', 'J2Hm3NUQJhU47AAyc3K9pNvpX4dprW', 'cn-shanghai')\n",
    "\n",
    "request = MakeSuperResolutionImageRequest()\n",
    "request.set_accept_format('json')\n",
    "\n",
    "request.set_Url(\"http://viapi-customer-temp.oss-cn-shanghai.aliyuncs.com/LTAI4G7iqc9nTRmEFPuYygZE/3c6c3f1a-3efb-4e7b-8041-c3cbd509ce51.jpg\")\n",
    "\n",
    "response = client.do_action_with_exception(request)\n",
    "# python2:  print(response) \n",
    "print(str(response, encoding='utf-8'))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {
    "ExecuteTime": {
     "end_time": "2020-07-09T18:15:20.041790Z",
     "start_time": "2020-07-09T18:15:19.421189Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "{\"Message\":\"success\",\"RequestId\":\"3BCB1FF5-B648-47C9-AB09-1D6222626FA3\",\"Data\":{\"ImageList\":[\"http://ivpd-cn-shanghai.oss-cn-shanghai.aliyuncs.com/upload/result_/2020-7-10/invi__015943185204451004042_8PkbdR.jpg?Expires=1594577720&OSSAccessKeyId=LTAI4FeJ8qKkYn6SrHhQ1DZQ&Signature=oQUvCq0Wt3UIsaunTh4P3eUPLko%3D\"]},\"Code\":\"0\"}\n"
     ]
    }
   ],
   "source": [
    "#色彩转换/拓色\n",
    "\n",
    "from aliyunsdkcore.client import AcsClient\n",
    "from aliyunsdkcore.acs_exception.exceptions import ClientException\n",
    "from aliyunsdkcore.acs_exception.exceptions import ServerException\n",
    "from aliyunsdkivpd.request.v20190625.RecolorImageRequest import RecolorImageRequest\n",
    "\n",
    "client = AcsClient('LTAI4G9jhGT9jJSGAgPSXzmC', 'J2Hm3NUQJhU47AAyc3K9pNvpX4dprW', 'cn-shanghai')\n",
    "\n",
    "request = RecolorImageRequest()\n",
    "request.set_accept_format('json')\n",
    "\n",
    "request.set_Url(\"http://viapi-customer-temp.oss-cn-shanghai.aliyuncs.com/LTAI4G7iqc9nTRmEFPuYygZE/f12a9bfd-19cc-4b66-b560-594f3645346c.jpg\")\n",
    "request.set_Mode(\"AUTO\")\n",
    "\n",
    "response = client.do_action_with_exception(request)\n",
    "# python2:  print(response) \n",
    "print(str(response, encoding='utf-8'))\n"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.3"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
